//
//  BIDNotifyViewController.m
//  商务厅
//
//  Created by mal on 13-12-9.
//  Copyright (c) 2013年 mal. All rights reserved.
//

#import "BIDLeaveViewController.h"
#import "BIDCreateLeaveViewController.h"
#import "BIDReceivedLeaveViewController.h"
#import "BIDCollectionCellView.h"
#import "BIDSentLeaveListViewController.h"

//角标
static NSString *leaveBadgeNumberURL = @"leaveAndroid!gainLeaveNotRead.action";

@interface BIDLeaveViewController ()

@end

@implementation BIDLeaveViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"请假申请";
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.imgArr = [[NSMutableArray alloc] initWithObjects:@"leave_add.png", @"leave_received.png", @"leave_sent.png", nil];
    self.titleArr = [[NSMutableArray alloc] initWithObjects:@"新建申请", @"已收申请", @"已发申请", nil];
}

- (void)viewWillAppear:(BOOL)animated
{
    [self refreshBadge];
}

- (void)pushNotificationHandler
{
    [self refreshBadge];
}

//刷新角标
- (void)refreshBadge
{
    NSNumber *index1 = [NSNumber numberWithInt:1];
    NSDictionary *dictionary1 = [[NSDictionary alloc] initWithObjectsAndKeys:index1, @"index", leaveBadgeNumberURL, @"url", nil];

    NSArray *arr = [[NSArray alloc] initWithObjects:dictionary1, nil];
    [self getCornerMarkCount:arr];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)backBtnHandler
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [self.navController popViewControllerAnimated:YES];
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger index = [indexPath row];
    switch (index) {
        case 0:
        {
            //新建申请
            BIDCreateLeaveViewController *vc = [[BIDCreateLeaveViewController alloc] initWithNibName:@"BIDCreateLeaveViewController" bundle:nil];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1:
        {
            //已收通知
            BIDReceivedLeaveViewController *vc = [[BIDReceivedLeaveViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2:
        {
            //已发通知
            BIDSentLeaveListViewController *vc = [[BIDSentLeaveListViewController alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
}

@end
